<script language='javascript'>
$(document).ready(function()
    {
    $("#${parameters.clearForm} input,#${parameters.clearForm} textarea,#${parameters.clearForm} select").change( function () {
			$('#cliFag').val(true);
	});
	$("#${parameters.clearForm} input,#${parameters.clearForm} textarea,#${parameters.clearForm} select").keydown( function (event) {
			$('#cliFag').val(true);
	});
	 $("#editButton").live("click", function() {
			$('#resFag').val(false);
			$('#ridaoValue').val($('input:radio[name=${parameters.radioName?html}][checked]').val());
		});
 }
);
	 function cl(){
		if($('#resFag').val()=="true"){
	    	if($('#cliFag').val()=="true"){
		    	$('#${parameters.clearForm}_openmsgId2').click();

				}
		}else{
		  if($('#cliFag').val()=="true"){
		  $('#${parameters.clearForm}_openmsgId1').click();
		  }
		}
      }

      function docl1(){
       $("input:radio[value="+$('#ridaoValue').val()+"]").attr("checked",'checked');
		    			$("#${parameters.editButtonId?html}").click();
		    			$('#cliFag').val(false);
      }

	function docl2(){
      		$("#${parameters.clearForm?html}")[0].reset();
						 $('.datepicker').each(function(){
						 var date=$(this).val();
						 $(this).val(date.substring(0, 4)+"/"+date.substring(5, 7)+"/"+date.substring(8, 10));
						 });
    }

    $.subscribe('${parameters.clearForm?html}_sn_dialog_setfocus1', function(event,data) {
	  $('#${parameters.clearForm}_clierdialog1').parent().find('.ui-dialog-buttonpane button').each(function(){
			if($(this).text()=="いいえ"){
				$(this).focus();
			}
		});
	});

	$.subscribe('${parameters.clearForm?html}_sn_dialog_setfocus2', function(event,data) {
	  $('#${parameters.clearForm}_clierdialog2').parent().find('.ui-dialog-buttonpane button').each(function(){
			if($(this).text()=="いいえ"){
				$(this).focus();
			}
		});
	});
</script>
<input type="hidden" id="resFag" value="true"/>
<input type="hidden" id="ridaoValue" value="000"/>
<input type="hidden" id="cliFag" value="false"/>
	 <input type="button"  class="button" value="クリア" onclick="cl()"/>

<@sj.dialog
    	id="${parameters.clearForm}_clierdialog1"
    	autoOpen="false"
    	buttons="{
    		'はい':function() { $('#${parameters.clearForm}_clierdialog1').dialog('close');docl1(); }
    		,'いいえ':function() { $('#${parameters.clearForm}_clierdialog1').dialog('close');}
    		}"
    	title="メッセージ"
    	modal="true"
    	onBeforeTopics="${parameters.clearForm}_sn_dialog_setfocus1"
    >
${parameters.msg?html}
    </@sj.dialog>
<@sj.a openDialog="${parameters.clearForm}_clierdialog1" value="open2" id="${parameters.clearForm}_openmsgId1" cssStyle="display:none" ></@sj.a>

<@sj.dialog
    	id="${parameters.clearForm}_clierdialog2"
    	autoOpen="false"
    	buttons="{
    		'はい':function() { $('#${parameters.clearForm}_clierdialog2').dialog('close');docl2(); }
    		,'いいえ':function() { $('#${parameters.clearForm}_clierdialog2').dialog('close');}
    		}"
    	title="メッセージ"
    	modal="true"
    	onBeforeTopics="${parameters.clearForm}_sn_dialog_setfocus2"
    >
${parameters.msg?html}
    </@sj.dialog>
<@sj.a openDialog="${parameters.clearForm}_clierdialog2" value="open2" id="${parameters.clearForm}_openmsgId2" cssStyle="display:none" ></@sj.a>
